package cn.lzd.mr.case8;

import com.alibaba.fastjson.JSONObject;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Created by lzd on 2018/8/10.
 */
public class Main2 {
    static List<String> list = new ArrayList<>();

    public static void main(String[] args) {
        try {
            List<String> list = FileUtils.readLines(new File("C:\\Users\\lzd\\Desktop\\会馆数据.txt"));
            list.stream().map((x) -> {
                String[] split = x.split("\\s+");
                if (split.length < 4) {
                    System.out.println(Arrays.toString(split));
                    return "-----";
                }
                String name = split[1];
                String url = split[3];
                JSONObject obj = new JSONObject();
                obj.put("companyName", name);
                obj.put("companyUrl", url);
                return obj;


            }).collect(Collectors.toSet())
                    .forEach((y)->{
                        if (y.toString().indexOf("companyUrl") != -1){
                            System.out.println(y);
                        }
                    });

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
